package com.lz.kunkun.messageservice.serviceImp;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lz.kunkun.messageservice.dao.ContactPeopleMapper;
import com.lz.kunkun.messageservice.model.ContactPeople;
import com.lz.kunkun.messageservice.service.IContactPeopleService;
import com.lz.kunkun.messageservice.util.TimeUtil;

/**
 * Hello world!
 *
 */
@Service("contactPeopleService")
public class ContactPeopleServiceImpl implements IContactPeopleService
{
	@Autowired
	ContactPeopleMapper contactPeopleMapper;

	@Override
	public int addPeople(ContactPeople people,Integer userId) {
		// TODO Auto-generated method stub
		return contactPeopleMapper.addPeople(userId,people.getName(),people.getPhoneNumber(),people.getImg(),people.getType(),people.getAddress(),people.getAge(),people.getSex(),TimeUtil.dateToString(new Date()));
	}

	@Override
	public ContactPeople getPeople(Integer peopleId,Integer userId) {
		// TODO Auto-generated method stub
		return contactPeopleMapper.getPeople(peopleId,userId);
	}

	@Override
	public int delPeople(Integer peopleId,Integer userId) {
		// TODO Auto-generated method stub
		return contactPeopleMapper.delPeople(peopleId,userId);
	}

	@Override
	public List<ContactPeople> allPeople(Integer userId,String keyword,String orderBy) {
		// TODO Auto-generated method stub
		return contactPeopleMapper.allPeople(userId,keyword,orderBy);
	}

	@Override
	public int updatePeople(ContactPeople people,Integer userId) {
		// TODO Auto-generated method stub
		return contactPeopleMapper.updatePeople(people.getPeopleId(),userId,people.getName(),people.getPhoneNumber(),people.getImg(),people.getType(),people.getAddress(),people.getAge(),people.getSex());
	}

	@Override
	public int getPeopleByPhone(Integer userId, String phoneNumber) {
		return contactPeopleMapper.getPeopleByPhone(userId,phoneNumber);
	}
}
